package com.example.firstproject.service;

import com.example.firstproject.entity.Student;
import com.example.firstproject.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public Map<String, Object> studentReqist(Student student){
        Map<String, Object> retData = new HashMap<>();
        Student userOld = studentMapper.getByStudentNumberOrUsername(student.getStudentNumber(),student.getUsername());
        if(userOld == null){
            studentMapper.insertStudent(student);
            retData.put("code",200);
            retData.put("message","success");
        }else {
            retData.put("code",500);
            retData.put("message","用户已注册");
        }
        return retData;

    }

    public void insert(Student student) {
    }
}

